/**
 */
package org.xtext.ic.dsl.icDsl.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import org.xtext.ic.dsl.icDsl.Connection;
import org.xtext.ic.dsl.icDsl.CreateDAO;
import org.xtext.ic.dsl.icDsl.IcDslPackage;
import org.xtext.ic.dsl.icDsl.Layer;
import org.xtext.ic.dsl.icDsl.Type;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Layer</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.xtext.ic.dsl.icDsl.impl.LayerImpl#getConnection <em>Connection</em>}</li>
 *   <li>{@link org.xtext.ic.dsl.icDsl.impl.LayerImpl#getCreatedao <em>Createdao</em>}</li>
 *   <li>{@link org.xtext.ic.dsl.icDsl.impl.LayerImpl#getTypes <em>Types</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class LayerImpl extends TypeImpl implements Layer
{
  /**
   * The cached value of the '{@link #getConnection() <em>Connection</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getConnection()
   * @generated
   * @ordered
   */
  protected Connection connection;

  /**
   * The cached value of the '{@link #getCreatedao() <em>Createdao</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getCreatedao()
   * @generated
   * @ordered
   */
  protected CreateDAO createdao;

  /**
   * The cached value of the '{@link #getTypes() <em>Types</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getTypes()
   * @generated
   * @ordered
   */
  protected EList<Type> types;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected LayerImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return IcDslPackage.Literals.LAYER;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Connection getConnection()
  {
    return connection;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetConnection(Connection newConnection, NotificationChain msgs)
  {
    Connection oldConnection = connection;
    connection = newConnection;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, IcDslPackage.LAYER__CONNECTION, oldConnection, newConnection);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setConnection(Connection newConnection)
  {
    if (newConnection != connection)
    {
      NotificationChain msgs = null;
      if (connection != null)
        msgs = ((InternalEObject)connection).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - IcDslPackage.LAYER__CONNECTION, null, msgs);
      if (newConnection != null)
        msgs = ((InternalEObject)newConnection).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - IcDslPackage.LAYER__CONNECTION, null, msgs);
      msgs = basicSetConnection(newConnection, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, IcDslPackage.LAYER__CONNECTION, newConnection, newConnection));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public CreateDAO getCreatedao()
  {
    return createdao;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetCreatedao(CreateDAO newCreatedao, NotificationChain msgs)
  {
    CreateDAO oldCreatedao = createdao;
    createdao = newCreatedao;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, IcDslPackage.LAYER__CREATEDAO, oldCreatedao, newCreatedao);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setCreatedao(CreateDAO newCreatedao)
  {
    if (newCreatedao != createdao)
    {
      NotificationChain msgs = null;
      if (createdao != null)
        msgs = ((InternalEObject)createdao).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - IcDslPackage.LAYER__CREATEDAO, null, msgs);
      if (newCreatedao != null)
        msgs = ((InternalEObject)newCreatedao).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - IcDslPackage.LAYER__CREATEDAO, null, msgs);
      msgs = basicSetCreatedao(newCreatedao, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, IcDslPackage.LAYER__CREATEDAO, newCreatedao, newCreatedao));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Type> getTypes()
  {
    if (types == null)
    {
      types = new EObjectContainmentEList<Type>(Type.class, this, IcDslPackage.LAYER__TYPES);
    }
    return types;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case IcDslPackage.LAYER__CONNECTION:
        return basicSetConnection(null, msgs);
      case IcDslPackage.LAYER__CREATEDAO:
        return basicSetCreatedao(null, msgs);
      case IcDslPackage.LAYER__TYPES:
        return ((InternalEList<?>)getTypes()).basicRemove(otherEnd, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case IcDslPackage.LAYER__CONNECTION:
        return getConnection();
      case IcDslPackage.LAYER__CREATEDAO:
        return getCreatedao();
      case IcDslPackage.LAYER__TYPES:
        return getTypes();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case IcDslPackage.LAYER__CONNECTION:
        setConnection((Connection)newValue);
        return;
      case IcDslPackage.LAYER__CREATEDAO:
        setCreatedao((CreateDAO)newValue);
        return;
      case IcDslPackage.LAYER__TYPES:
        getTypes().clear();
        getTypes().addAll((Collection<? extends Type>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case IcDslPackage.LAYER__CONNECTION:
        setConnection((Connection)null);
        return;
      case IcDslPackage.LAYER__CREATEDAO:
        setCreatedao((CreateDAO)null);
        return;
      case IcDslPackage.LAYER__TYPES:
        getTypes().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case IcDslPackage.LAYER__CONNECTION:
        return connection != null;
      case IcDslPackage.LAYER__CREATEDAO:
        return createdao != null;
      case IcDslPackage.LAYER__TYPES:
        return types != null && !types.isEmpty();
    }
    return super.eIsSet(featureID);
  }

} //LayerImpl
